class Solution:
    # 此方法超时了
    def greatestLetter(self, s: str) -> str:
        max = 'A'
        # 字典存储
        flag = 0
        for i in s:
            for j in range(1,len(s)):
                if abs(ord(s[j])-ord(i)) == abs(ord('A')-ord('a')):
                    if i.upper() >max:
                        max = i.upper()
                        flag = 1
        if flag == 1:
            return max
        else:
            return ""
    def greatestLetter1(self, s: str) -> str:
        # 字典存储
        char_list = list()
        char_dict = {}
        for i in s:
            if 'a'<=i<='z':
                if i not in char_dict:
                    char_dict[ord(i)] = 1
        for i in s:
            if 'A'<=i <='Z':
                if ord(i)+32 in char_dict:
                    char_list.append(ord(i))
        print(char_list)
        if  char_list:
            return chr(max(char_list))
        else:
            return ""










if __name__ == '__main__':
    s = "lEeTcOdE"
    solution = Solution()
    val = solution.greatestLetter1(s)
    print(val)
